home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Add-Ons / MPW / MPW dmake 4.0 / imacs.c < prev    next >
Text File  |  1995-09-22  |  6KB  |  183 lines

  1. /* RCS      -- $Header: /u5/dvadura/src/public/dmake/src/RCS/imacs.c,v 1.1 1994/10/06 17:42:40 dvadura Exp $
  2. -- SYNOPSIS -- define default internal macros.
  3. -- 
  4. -- DESCRIPTION
  5. --    This file adds to the internal macro tables the set of default
  6. --    internal macros, and for those that are accessible internally via
  7. --    variables creates these variables, and initializes them to point
  8. --    at the default values of these macros.
  9. --
  10. -- AUTHOR
  11. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  12. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  13. --
  14. -- COPYRIGHT
  15. --      Copyright (c) 1992,1994 by Dennis Vadura.  All rights reserved.
  16. -- 
  17. --      This program is free software; you can redistribute it and/or
  18. --      modify it under the terms of the GNU General Public License
  19. --      (version 1), as published by the Free Software Foundation, and
  20. --      found in the file 'LICENSE' included with this distribution.
  21. -- 
  22. --      This program is distributed in the hope that it will be useful,
  23. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  24. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  25. --      GNU General Public License for more details.
  26. -- 
  27. --      You should have received a copy of the GNU General Public License
  28. --      along with this program;  if not, write to the Free Software
  29. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  30. --
  31. -- LOG
  32. --     $Log: imacs.c,v $
  33.  * Revision 1.1  1994/10/06  17:42:40  dvadura
  34.  * dmake Release Version 4.0, Initial revision
  35.  *
  36. */
  37.  
  38. #include "extern.h"
  39.  
  40. static    void    _set_int_var ANSI((char *, char *, int, int *));
  41. static    void    _set_string_var ANSI((char *, char *, int, char **));
  42. static    void    _set_bit_var ANSI((char *, char *, int));
  43.  
  44. /*
  45. ** Arrange to parse the strings stored in Rules[]
  46. */
  47. PUBLIC void
  48. Make_rules()
  49. {
  50.    Parse(NIL(FILE));
  51. }
  52.  
  53.  
  54. #define M_FLAG   M_DEFAULT | M_EXPANDED
  55.  
  56. /*
  57. ** Add to the macro table all of the internal macro variables plus
  58. ** create secondary variables which will give access to their values
  59. ** easily, both when needed and when the macro value is modified.
  60. ** The latter is accomplished by providing a flag in the macro and a field
  61. ** which gives a pointer to the value if it is a char or string macro value
  62. ** and a mask representing the bit of the global flag register that is affected
  63. ** by this macro's value.
  64. */
  65. PUBLIC void
  66. Create_macro_vars()
  67. {
  68.    static char* switchar;
  69.    char   swchar[2];
  70.    char   buf[20];
  71.  
  72.    swchar[0] = Get_switch_char(), swchar[1] = '\0';
  73.    _set_string_var("SWITCHAR", swchar, M_PRECIOUS, &switchar);
  74. #ifdef macintosh
  75.    _set_string_var("DIRSEPSTR", ":",M_DEFAULT,&DirSepStr);
  76. #else
  77.    _set_string_var("DIRSEPSTR", (*swchar=='/')?"\\":"/",M_DEFAULT,&DirSepStr);
  78. #endif
  79.    _set_string_var("DIRBRKSTR", DirBrkStr, M_DEFAULT, &DirBrkStr);
  80.    swchar[0] = DEF_ESCAPE_CHAR, swchar[1] = '\0';
  81.    _set_string_var(".ESCAPE_PREFIX", swchar, M_FLAG, &Escape_char);
  82.  
  83.    _set_bit_var(".SILENT",   "", A_SILENT  );
  84.    _set_bit_var(".IGNORE",   "", A_IGNORE  );
  85.    _set_bit_var(".PRECIOUS", "", A_PRECIOUS);
  86.    _set_bit_var(".EPILOG",   "", A_EPILOG  );
  87.    _set_bit_var(".PROLOG",   "", A_PROLOG  );
  88.    _set_bit_var(".NOINFER",  "", A_NOINFER );
  89.    _set_bit_var(".SEQUENTIAL","",A_SEQ     );
  90.    _set_bit_var(".USESHELL", "", A_SHELL   );
  91.    _set_bit_var(".SWAP",     "", A_SWAP    );
  92.    _set_bit_var(".MKSARGS",  "", A_MKSARGS );
  93.    _set_bit_var(".IGNOREGROUP","",A_IGNOREGROUP);
  94.  
  95.    Glob_attr = A_DEFAULT;        /* set all flags to NULL   */
  96.  
  97.    _set_string_var("SHELL",        "",  M_DEFAULT, &Shell       );
  98.    _set_string_var("SHELLFLAGS",   " ", M_DEFAULT, &Shell_flags );
  99.    _set_string_var("GROUPSHELL",   "",  M_DEFAULT, &GShell      );
  100.    _set_string_var("GROUPFLAGS",   " ", M_DEFAULT, &GShell_flags);
  101.    _set_string_var("SHELLMETAS",   "",  M_DEFAULT, &Shell_metas );
  102.    _set_string_var("GROUPSUFFIX",  "",  M_DEFAULT, &Grp_suff    );
  103.    _set_string_var("AUGMAKE",NIL(char), M_DEFAULT, &Augmake     );
  104.    _set_string_var(".KEEP_STATE",  "",  M_DEFAULT, &Keep_state  );
  105.    _set_string_var(".NOTABS",      "",  M_MULTI,   &Notabs      );
  106.    _set_string_var(".DIRCACHE",    "y", M_DEFAULT, &UseDirCache );
  107.  
  108.    _set_string_var("MAKEDIR",Get_current_dir(),M_PRECIOUS|M_NOEXPORT,&Makedir);
  109.    _set_string_var("PWD",  Makedir,  M_DEFAULT|M_NOEXPORT, &Pwd);
  110.    _set_string_var("TMD",  "",       M_DEFAULT|M_NOEXPORT, &Tmd);
  111.  
  112.    Def_macro("NULL", "", M_PRECIOUS|M_NOEXPORT|M_FLAG);
  113.  
  114.    _set_int_var( "MAXLINELENGTH", "0", M_DEFAULT|M_NOEXPORT, &Buffer_size );
  115.    _set_int_var( "PREP",          "0", M_DEFAULT, &Prep );
  116.    (void) Def_macro("MAXLINELENGTH", "1024", M_FLAG | M_DEFAULT);
  117.  
  118.    /* set MAXPROCESSLIMIT high initially so that it allows MAXPROCESS to
  119.     * change from command line. */
  120.    _set_int_var( "MAXPROCESSLIMIT", "100", M_DEFAULT|M_NOEXPORT,&Max_proclmt );
  121.    _set_int_var( "MAXPROCESS", "1", M_DEFAULT|M_NOEXPORT, &Max_proc );
  122.    _set_int_var( "DYNAMICNESTINGLEVEL", "100", M_DEFAULT|M_NOEXPORT,
  123.          &DynamicNestLevel);
  124.    sprintf(buf,"%d",NAME_MAX);
  125.    _set_int_var( "NAMEMAX", buf, M_DEFAULT|M_NOEXPORT, &NameMax);
  126. }
  127.  
  128.  
  129. /*
  130. ** Define an integer variable value, and set up the macro.
  131. */
  132. static void
  133. _set_int_var(name, val, flag, var)
  134. char *name;
  135. char *val;
  136. int  flag;
  137. int  *var;
  138. {
  139.    HASHPTR hp;
  140.  
  141.    hp = Def_macro(name, val, M_FLAG | flag);
  142.    hp->ht_flag |= M_VAR_INT | M_MULTI;
  143.    hp->MV_IVAR  = var;
  144.    *var         = atoi(val);
  145. }
  146.  
  147.  
  148. /*
  149. ** Define a string variables value, and set up the macro.
  150. */
  151. static void
  152. _set_string_var(name, val, flag, var)
  153. char *name;
  154. char *val;
  155. int  flag;
  156. char **var;
  157. {
  158.    HASHPTR hp;
  159.  
  160.    hp = Def_macro(name, val, M_FLAG | flag);
  161.    hp->ht_flag |= M_VAR_STRING | M_MULTI;
  162.    hp->MV_SVAR  = var;
  163.    *var         = hp->ht_value;
  164. }
  165.  
  166.  
  167. /*
  168. ** Define a bit variable value, and set up the macro.
  169. */
  170. static void
  171. _set_bit_var(name, val, mask)
  172. char *name;
  173. char *val;
  174. int  mask;
  175. {
  176.    HASHPTR hp;
  177.  
  178.    hp           = Def_macro(name, val, M_FLAG);
  179.    hp->ht_flag |= M_VAR_BIT | M_MULTI;
  180.    hp->MV_MASK  = mask;
  181.    hp->MV_BVAR  = &Glob_attr;
  182. }
  183.